package com.mmy.fta.usercenter.service.impl;

import com.github.pagehelper.util.StringUtil;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import com.mmy.fta.usercenter.aliyunmsg.SmsUtil;
import com.mmy.fta.usercenter.api.UserService;
import com.mmy.fta.usercenter.bo.UserBO;
import com.mmy.fta.usercenter.dto.*;
import com.mmy.fta.usercenter.entity.*;
import com.mmy.fta.usercenter.repository.*;
import com.mmy.fta.usercenter.request.VerifyRequest;
import com.mmy.fta.usercenter.utils.ToolUtils;
import com.ymm.common.rpc.YmmResult;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.Service;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;

/**
 * @author qingyu.meng
 * @apiNote 用户中心service
 * @date 2021年10月19日 7:17 下午
 * @Description
 */
@Service
@Slf4j
public class UserServiceImpl implements UserService {
    @Autowired
    OpenidUserMapper openidUserMapper;

    @Autowired
    DriverInfoEntityMapper driverInfoEntityMapper;

    @Autowired
    ShipperInfoEntityMapper shipperInfoEntityMapper;

    @Autowired
    UserBO userBO;

    @Autowired
    DriverMembershipEntityMapper driverMembershipEntityMapper;

    @Autowired
    ShipperMembershipEntityMapper shipperMembershipEntityMapper;

    @Autowired
    CouponEntityMapper couponEntityMapper;

    private static final Logger LOGGER = LoggerFactory.getLogger(UserServiceImpl.class);

    private static Cache<String, String> VERIFY_CODE_CACHE = CacheBuilder
            .newBuilder()
            .expireAfterWrite(300, TimeUnit.SECONDS)
            .build();

    /**
     * 用户一键登录
     *
     * @param openId
     * @return
     */
    @Override
    public YmmResult<UserDTO> login(String openId) {
        //extracted();

        LOGGER.info(">>>>>>>>>>>>UserService:login(String openId) 请求参数为：" + openId);
        OpenidUserEntity user = openidUserMapper.selectByOpenId(openId);
        UserDTO userDTO = new UserDTO();
        // 首次初测登录则需要保存openId、增加次数和优惠券权益到数据库
        if (Objects.isNull(user)) {
            YmmResult ymmResult = userBO.saveOpenId(openId);
            if (!ymmResult.isSuccess()) {
                return YmmResult.failResult(000, "登录失败，请稍后再试~");
            }
            user = openidUserMapper.selectByOpenId(openId);
        }
        Integer appType = user.getAppType();
        String endTimeFormat = null;
        int freetime = openidUserMapper.selectFreetime(openId);
        int coupons = openidUserMapper.selectCoupons(openId);

        if (appType == 0) {//司机端
            int driverMemberShipstatus = openidUserMapper.selectDriverMemberShipStatus(openId);
            if (Objects.equals(driverMemberShipstatus, 0)) {
                BeanUtils.copyProperties(user, userDTO);
                userDTO.setMemberShipEndTime(endTimeFormat);
                userDTO.setIs_valid(freetime);
                userDTO.setCoupons(coupons);
                return YmmResult.succResult(userDTO);
            }
            DriverMembershipEntity driverMembershipEntity = driverMembershipEntityMapper.selectByOpenId(openId);

            Date endTime = driverMembershipEntity.getNormalEndTime();
            if (Objects.isNull(endTime)) {
                userDTO.setMemberShipEndTime(endTimeFormat);
            } else {
                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("YYYY-MM-dd");
                endTimeFormat = simpleDateFormat.format(endTime);
                userDTO.setMemberShipEndTime(endTimeFormat);
            }


            BeanUtils.copyProperties(user, userDTO);

            userDTO.setIs_valid(freetime);
            userDTO.setCoupons(coupons);
            log.info("司机登录信息:{}", userDTO);
            return YmmResult.succResult(userDTO);
        } else {//货主端
            int shipperMemberShipstatus = openidUserMapper.selectShipperMemberShipStatus(openId);
            if (Objects.equals(shipperMemberShipstatus, 0)) {
                BeanUtils.copyProperties(user, userDTO);
                userDTO.setMemberShipEndTime(endTimeFormat);
                userDTO.setIs_valid(freetime);
                userDTO.setCoupons(coupons);
                return YmmResult.succResult(userDTO);
            }
            ShipperMembershipEntity shipperMembershipEntity = shipperMembershipEntityMapper.selectByOpenId(openId);
            Date endTime = shipperMembershipEntity.getNormalEndTime();
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("YYYY-MM-dd");
            endTimeFormat = simpleDateFormat.format(endTime);
            BeanUtils.copyProperties(user, userDTO);
            userDTO.setMemberShipEndTime(endTimeFormat);
            userDTO.setIs_valid(freetime);
            userDTO.setCoupons(coupons);
            log.info("货主登录信息:{}", userDTO);
            return YmmResult.succResult(userDTO);
        }
    }


    /**
     * 用户实名认证
     *
     * @param verifyRequest
     * @return
     */
    @Override
    @Transactional
    public YmmResult<UserDTO> verify(VerifyRequest verifyRequest) throws Exception {
        if (Objects.isNull(verifyRequest)) {
            return YmmResult.failResult(000, "virifyRequest is null");
        }
        Integer appType = verifyRequest.getAppType();

        if (appType == 0) {// 司机端
            DriverInfoEntity driverInfoEntity = new DriverInfoEntity();
            driverInfoEntity.setUserName(verifyRequest.getName());
            driverInfoEntity.setOpenId(verifyRequest.getToken());
            driverInfoEntity.setIdentityNo(verifyRequest.getIdentityNo());
            driverInfoEntity.setTelephone(verifyRequest.getTelephone());
            //新注册司机赠送3次免技术服务费和0张券
            driverInfoEntity.setFreetime(3);
            driverInfoEntity.setCoupons(0);
            int insertResult = driverInfoEntityMapper.insertSelective(driverInfoEntity);

            OpenidUserEntity openidUserEntity = new OpenidUserEntity();
            openidUserEntity.setOpenId(verifyRequest.getToken());
            openidUserEntity.setIdentityNo(verifyRequest.getIdentityNo());
            openidUserEntity.setAppType(0);
            openidUserEntity.setIsValid(3);
            openidUserEntity.setIsAuth(1);
            openidUserEntity.setIsMembership(0);
            int insertResultOpenidUser = openidUserMapper.updateMsg(openidUserEntity);
//            int insertResultOpenidUser = insertResultOpenidUser(driverInfoEntity, appType);
            if (insertResult == 0 && insertResultOpenidUser == 0) {
                throw new Exception("实名认证保存司机信息异常");
            }
        } else {
            // 货主端
            ShipperInfoEntity shipperInfoEntity = new ShipperInfoEntity();
            shipperInfoEntity.setUserName(verifyRequest.getName());
            shipperInfoEntity.setOpenId(verifyRequest.getToken());
            shipperInfoEntity.setIdentityNo(verifyRequest.getIdentityNo());
            shipperInfoEntity.setTelephone(verifyRequest.getTelephone());
            //新注册货主送90次免费发货和0张券
            shipperInfoEntity.setRemianDeliverys(90);
            shipperInfoEntity.setDeliverys(0);
            int insert = shipperInfoEntityMapper.insertSelective(shipperInfoEntity);

            OpenidUserEntity openidUserEntity = new OpenidUserEntity();
            openidUserEntity.setOpenId(verifyRequest.getToken());
            openidUserEntity.setIdentityNo(verifyRequest.getIdentityNo());
            openidUserEntity.setAppType(1);
            openidUserEntity.setIsValid(90);
            openidUserEntity.setIsAuth(1);
            openidUserEntity.setIsMembership(0);
            int insertResultOpenidUser = openidUserMapper.updateMsg(openidUserEntity);

            if (insert == 0 && insertResultOpenidUser == 0) {
                throw new Exception("实名认证保存货主信息异常");
            }
        }

        // 将openId关联到具体用户
        OpenidUserEntity openidUserEntity = new OpenidUserEntity();
        openidUserEntity.setOpenId(verifyRequest.getToken());
        openidUserEntity.setIdentityNo(verifyRequest.getIdentityNo());
        openidUserEntity.setAppType(verifyRequest.getAppType());
        openidUserEntity.setIsAuth(1);
        int result = openidUserMapper.updateByOpenIdSelective(openidUserEntity);
        if (result == 0) {
            throw new Exception("实名认证司机关联openId异常");
        }

        UserDTO userDTO = new UserDTO();
        userDTO.setIsAuth(1);

        return YmmResult.succResult(userDTO);
    }

    private int insertResultOpenidUser(VerifyRequest verifyRequest, int apptype) {
        OpenidUserEntity openidUserEntity = new OpenidUserEntity();
        openidUserEntity.setOpenId(verifyRequest.getToken());
        openidUserEntity.setIdentityNo(verifyRequest.getIdentityNo());
        if(Objects.equals(apptype,0)){
            openidUserEntity.setAppType(0);
            openidUserEntity.setIsValid(3);
        }else{
            openidUserEntity.setAppType(1);
            openidUserEntity.setIsValid(90);
        }
        openidUserEntity.setIsAuth(1);
        openidUserEntity.setIsMembership(0);
        return openidUserMapper.updateMsg(openidUserEntity);
    }


    /**
     * 用户身份证OCR识别
     *
     * @return
     */
    @Override
    public YmmResult<UserDTO> OCRMessage() {
        LOGGER.info(">>>>>>>>>>>>>userService:OCRMessage<<<<<<<<<<<<<<<<<");
        String chineseName = ToolUtils.generateChineseName();
        String identityNo = ToolUtils.generateIdentityNum();
        String date = ToolUtils.generateDate();
        UserDTO userDTO = new UserDTO();
        userDTO.setIdentityNo(identityNo);
        userDTO.setName(chineseName);
//        userDTO.setName("从蓓竹");
        userDTO.setValidityTime(date);
        return YmmResult.succResult(userDTO);
    }

    /**
     * 行驶证OCR识别
     *
     * @return
     */
    @Override
    public YmmResult<DrivingLicenseDTO> drivingLicenseOCR() {
        LOGGER.info(">>>>>>>>>>>>>userService:drivingLicenseOCR<<<<<<<<<<<<<<<<<");
        DrivingLicenseDTO drivingLicenseDTO = new DrivingLicenseDTO();
        drivingLicenseDTO.setDriverCarNo("川AU7987");
        drivingLicenseDTO.setCarLengthType("平板/17.5米");
        drivingLicenseDTO.setTruckType("重型厢式货车");
        drivingLicenseDTO.setOwner("刘永军");
        drivingLicenseDTO.setCarWeight("2500");
        drivingLicenseDTO.setDrivingLicenseNo("51X0040424566");
        return YmmResult.succResult(drivingLicenseDTO);
    }

    /**
     * 驾驶证OCR识别
     *
     * @return
     */
    @Override
    public YmmResult<DriverLicenseDTO> driverLicenseOCR() {
        LOGGER.info(">>>>>>>>>>>>>userService:driverLicenseOCR<<<<<<<<<<<<<<<<<");
        DriverLicenseDTO driverLicenseDTO = new DriverLicenseDTO();
        driverLicenseDTO.setUserName("刘永军");
        driverLicenseDTO.setDriverLicenseNo("793286748797");
        driverLicenseDTO.setQuasiDrivingType("A1");
        driverLicenseDTO.setBeginGetLicense("2018-12-06");
        driverLicenseDTO.setValidityTime("2028-12-06");
        return YmmResult.succResult(driverLicenseDTO);
    }

    /**
     * 根据openId查询对应用户信息
     *
     * @param openId
     * @return
     */
    @Override
    public YmmResult<ShipperDTO> queryByOpenId(String openId) {
        log.info(">>>>>>>>>>>>根据openId查询货主信息<<<<<<<<<<<<<<<<<<");
        if (StringUtil.isEmpty(openId)) {
            return YmmResult.failResult(000, "参数为null");
        }
        OpenidUserEntity openidUserEntity = openidUserMapper.selectByOpenId(openId);
        if (Objects.isNull(openidUserEntity)) {
            return YmmResult.failResult(000, "openId: " + openId + " 无对应的用户");
        }
        String identityNo = openidUserEntity.getIdentityNo();
        ShipperInfoEntity shipperInfoEntity = shipperInfoEntityMapper.selectByIdentityNo(identityNo);
        if (Objects.isNull(shipperInfoEntity)) {
            return YmmResult.failResult(000, "identityNo: " + identityNo + " 无对应用户");
        }
        ShipperInfoEntity result = shipperInfoEntityMapper.selectByPrimaryKey(shipperInfoEntity.getId());
        System.out.println(result);
        ShipperDTO shipperDTO = new ShipperDTO();
        BeanUtils.copyProperties(result, shipperDTO);
        return YmmResult.succResult(shipperDTO);
    }

    @Override
    public String queryShipperPhoneNumber(String openId) {
        String shipperIdNo = openidUserMapper.queryShipperIdNo(openId);
        return shipperInfoEntityMapper.queryShipperPhoneNumber(shipperIdNo);
    }

    @Override
    public YmmResult<ShipperDTO> queryByShipperIdentityId(String identityId) {
        LOGGER.info(">>>>>>>>>>>>>>根据货主身份证号查询货主信息<<<<<<<<<<<<<<<<<<");
        if (StringUtil.isEmpty(identityId)) {
            return YmmResult.failResult(000, "请求参数为null");
        }
        ShipperInfoEntity shipperInfoEntity = shipperInfoEntityMapper.selectByIdentityNo(identityId);
        if (Objects.isNull(shipperInfoEntity)) {
            return YmmResult.failResult(000, "对应的货主用户不存在");
        }
        ShipperDTO shipperDTO = new ShipperDTO();
        BeanUtils.copyProperties(shipperInfoEntity, shipperDTO);
        return YmmResult.succResult(shipperDTO);
    }

    /**
     * 根据openId查询司机详细信息
     *
     * @param openId
     * @return
     */
    @Override
    public YmmResult<DriverDTO> queryDriverInfoByOpenId(String openId) {
        if (StringUtil.isEmpty(openId)) {
            return YmmResult.failResult(000, "参数为null");
        }
        OpenidUserEntity openidUserEntity = openidUserMapper.selectByOpenId(openId);
        if (Objects.isNull(openidUserEntity)) {
            return YmmResult.failResult(000, "openId: " + openId + " 无对应的用户");
        }
        String identityNo = openidUserEntity.getIdentityNo();
        DriverInfoEntity driverInfoEntity = driverInfoEntityMapper.selectByIdentityNo(identityNo);
        if (Objects.isNull(driverInfoEntity)) {
            return YmmResult.failResult(000, "identityNo: " + identityNo + " 无对应用户");
        }
        DriverInfoEntity result = driverInfoEntityMapper.selectByPrimaryKey(driverInfoEntity.getId());
        DriverDTO driverDTO = new DriverDTO();
        BeanUtils.copyProperties(result, driverDTO);
        return YmmResult.succResult(driverDTO);
    }

    /**
     * 货主发货
     *
     * @param identityNo
     * @return
     */
    @Override
    public YmmResult sendCargo(String identityNo) {
        log.info("UserService:sendCargo,identityNo is {}", identityNo);
        if (StringUtil.isEmpty(identityNo)) {
            return YmmResult.failResult(000, "参数为null");
        }
        ShipperInfoEntity shipperInfoEntity = shipperInfoEntityMapper.selectByIdentityNo(identityNo);
        if (Objects.isNull(shipperInfoEntity)) {
            return YmmResult.failResult(000, "该identityNo对应的货主不存在");
        }
        // 已发货次数
        Integer deliverys = shipperInfoEntity.getDeliverys();
        // 剩余发货次数
        Integer remianDeliverys = shipperInfoEntity.getRemianDeliverys();
        if (remianDeliverys <= 0) {
            return YmmResult.failResult(000, "剩余发货次数不足");
        }

        deliverys++;
        remianDeliverys--;

        ShipperInfoEntity shipperInfoUpdateEntity = new ShipperInfoEntity();
        shipperInfoUpdateEntity.setDeliverys(deliverys);
        shipperInfoUpdateEntity.setRemianDeliverys(remianDeliverys);
        shipperInfoUpdateEntity.setId(shipperInfoEntity.getId());
        int result = shipperInfoEntityMapper.updateByPrimaryKeySelective(shipperInfoUpdateEntity);
        if (result == 0) {
            return YmmResult.failResult(000, "发货失败");
        }

        return YmmResult.succResult();
    }

    /**
     * 发送短信验证码
     *
     * @return
     */
    @Override
    public YmmResult sendVerifyCode(String phoneNumber) {
        //String verifyCode = SmsUtil.produceVerifyCode();
        String verifyCode = "123456";
        VERIFY_CODE_CACHE.put(phoneNumber, verifyCode);
        //SmsUtil.sendSms(phoneNumber,verifyCode);
        return YmmResult.succResult();
    }

    @Override
    public YmmResult sendMessage(String phoneNumber, String code) {
        SmsUtil.sendSms(phoneNumber,code);
        return YmmResult.succResult();
    }


    /**
     * 验证短信验证码
     *
     * @param phoneNumber
     * @param verifyCode
     * @return
     */
    @Override
    public YmmResult verifyCode(String phoneNumber, String verifyCode) {
        String code = VERIFY_CODE_CACHE.getIfPresent(phoneNumber);
        if (Objects.equals(verifyCode, code)) {
            return YmmResult.succResult();
        }
        return YmmResult.failResult(000, "请输入正确的验证码");
    }

    /**
     * 保存行驶证信息
     *
     * @param drivingLicenseDTO
     * @param openId
     * @return
     */
    @Override
    public YmmResult saveDrivingLicenseInfo(DrivingLicenseDTO drivingLicenseDTO, String openId) {
        log.info(">>>>>>UserService:saveDrivingLicenseInfo,drivingLicenseDTO is {},openId is {}", drivingLicenseDTO, openId);
        OpenidUserEntity openidUserEntity = openidUserMapper.selectByOpenId(openId);
        String identityNo = openidUserEntity.getIdentityNo();
        DriverInfoEntity driverInfoEntity = driverInfoEntityMapper.selectByIdentityNo(identityNo);
        System.out.println("driverInfoEntity: " + driverInfoEntity);
        BeanUtils.copyProperties(drivingLicenseDTO, driverInfoEntity);
        System.out.println("drivingLicenseDTO: " + drivingLicenseDTO);
        System.out.println("driverInfoEntity: " + driverInfoEntity);
        driverInfoEntity.setDriverVehicleNo(drivingLicenseDTO.getDrivingLicenseNo());
        int updateResult = driverInfoEntityMapper.updateByPrimaryKeySelective(driverInfoEntity);
        if (updateResult == 0) {
            return YmmResult.failResult(000, "保存用户行驶证信息失败");
        }
        return YmmResult.succResult();
    }

    /**
     * 保存驾驶证信息
     *
     * @param driverLicenseDTO
     * @param openId
     * @return
     */
    @Override
    public YmmResult saveDriverLicenseInfo(DriverLicenseDTO driverLicenseDTO, String openId) {
        log.info(">>>>>>>>>UserService:saveDriverLicenseInfo,driverLicenseDTO is{},openId is{}<<<<<<<<<<", driverLicenseDTO, openId);
        OpenidUserEntity openidUserEntity = openidUserMapper.selectByOpenId(openId);
        String identityNo = openidUserEntity.getIdentityNo();
        DriverInfoEntity driverInfoEntity = driverInfoEntityMapper.selectByIdentityNo(identityNo);
        BeanUtils.copyProperties(driverLicenseDTO, driverInfoEntity);
        driverInfoEntity.setCertificateStatus(1);
        int updateResult = driverInfoEntityMapper.updateByPrimaryKeySelective(driverInfoEntity);
        if (updateResult == 0) {
            return YmmResult.failResult(000, "保存用户驾驶证信息失败");
        }
        return YmmResult.succResult();
    }

    @Override
    public YmmResult saveDriverInfo(DriverDTO driverDTO, String openId) {
        log.info(">>>>>>UserService:saveDriverInfo,driverDTO is{},openId is{}<<<<<<", driverDTO, openId);
        // 将openId和司机identity关联起来
        OpenidUserEntity openidUserEntity = openidUserMapper.selectByOpenId(openId);
        openidUserEntity.setIdentityNo(driverDTO.getIdentityNo());
        openidUserEntity.setIsAuth(1);
        openidUserEntity.setIsValid(3);
        int update = openidUserMapper.updateByOpenIdSelective(openidUserEntity);
        if (update == 0) {
            return YmmResult.failResult(000, "openId关联identityNo失败");
        }

        DriverInfoEntity driverInfoEntity = new DriverInfoEntity();
        BeanUtils.copyProperties(driverDTO, driverInfoEntity);
        int saveResult = driverInfoEntityMapper.insertSelective(driverInfoEntity);
        if (saveResult == 0) {
            return YmmResult.failResult(000, "保存司机信息失败");
        }

        return YmmResult.succResult();
    }

    @Override
    public YmmResult<DriverInterestsDTO> queryDriverInterests(String openId) {
        log.info(">>>>>>>>>UserService:queryDriverInterests,request is:({})<<<<<<<<<", openId);
        DriverInterestsDTO driverInterestsDTO = new DriverInterestsDTO();
        OpenidUserEntity openidUserEntity = openidUserMapper.selectByOpenId(openId);

        if (Objects.isNull(openidUserEntity)) {
            return YmmResult.failResult(000, "该openId对应的用户不存在");
        }

        Integer isMembership = openidUserEntity.getIsMembership();
        driverInterestsDTO.setIsMembership(isMembership);

        driverInterestsDTO.setFreeTimes((long) openidUserEntity.getIsValid());

        // 非会员
//        if (isMembership == 0) {
//            driverInterestsDTO.setFreeTimes(0L);
//        }


        // 会员
//        DriverMembershipEntity driverMembershipEntity = driverMembershipEntityMapper.selectByOpenId(openId);
//
//        if (Objects.isNull(driverMembershipEntity)) {
//            driverInterestsDTO.setFreeTimes(0L);
//            return YmmResult.failResult(000, "该openId对应的会员用户不存在");
//        }else{
//
//            driverInterestsDTO.setFreeTimes(driverMembershipEntity.getFreeTimes());
//        }


        // 查询优惠券
        List<CouponDTO> coupons = new ArrayList<>();
        List<CouponEntity> couponEntities = couponEntityMapper.selectByOpenId(openId);

        if (couponEntities == null || couponEntities.isEmpty()) {
            driverInterestsDTO.setCoupons(coupons);
            return YmmResult.succResult(driverInterestsDTO);
        }

        for (CouponEntity couponEntity : couponEntities) {
            CouponDTO couponDTO = new CouponDTO();
            BeanUtils.copyProperties(couponEntity, couponDTO);
            couponDTO.setCouponId(couponEntity.getId().toString());
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
            String format = simpleDateFormat.format(couponDTO.getEndTime());
            couponDTO.setEndTimeFormat(format);
            coupons.add(couponDTO);
        }

        List<CouponDTO> collect = coupons.stream().sorted(new Comparator<CouponDTO>() {
            @Override
            public int compare(CouponDTO o1, CouponDTO o2) {
                return o1.getEndTime().before(o2.getEndTime()) ? -1 : 1;
            }
        }).sorted(new Comparator<CouponDTO>() {
            @Override
            public int compare(CouponDTO o1, CouponDTO o2) {
                return o1.getCouponAmount() - o2.getCouponAmount() >= 0 ? 1 : -1;
            }
        }).limit(3).collect(Collectors.toList());
        driverInterestsDTO.setCoupons(collect);
        log.info(">>>>>>UserService:queryDriverInterests return is {}", driverInterestsDTO);
        return YmmResult.succResult(driverInterestsDTO);
    }

    @Override
    public String queryShipperPhone(String openId) {
        String idNo = openidUserMapper.queryShipperIdNo(openId);
        String shipperPhone = shipperInfoEntityMapper.selectByIdentityNo(idNo).getTelephone();

        return shipperPhone;
    }

    @Override
    public boolean queryShipperIsColdMember(String openId) {
        return openidUserMapper.queryShipperIsColdMember(openId) == 1;
    }

    @Override
    public void updateShipperForCancelOrderByDriver(String openId) {
        openidUserMapper.addShipperSendCargoTimes(openId);
        shipperInfoEntityMapper.addShipperSendCargoTimes(openId);
        if(openidUserMapper.selectShipperIsNormalMembership(openId)==1){
            shipperMembershipEntityMapper.updateShipperSendCargoTimes(openId);
        }
    }


    /**
     * 身份信息映射
     */
    private void extracted() {
        Map<String, String> identityMap = new HashMap<>();
        identityMap.put("o4ZIg47fUX_fpbvoq6uCsTIyBldQ", "140402198009032209");
        identityMap.put("oilYF5Oto7hA6KM_9G42LZ4mFwXM", "32072119780603563X");
    }

}
